package com.wyzz.hr.base.wf.leaverequest;

import java.math.BigDecimal;
import java.util.*;
import org.apache.commons.lang.StringUtils;

import com.wyzz.hr.base.ComonBeans;
import com.wyzz.hr.base.Status;
import com.wyzz.hr.base.wf.AbstractWfApproverAction;
import com.wyzz.hr.bo.IAttendshiftBO;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.bo.ILeaverequestBO;
import com.wyzz.hr.bo.ILeavetypeBO;
import com.wyzz.hr.bo.IOvertimerequestBo;
import com.wyzz.hr.bo.IOvertimetxusedBO;
import com.wyzz.hr.bo.ISysLogBO;
import com.wyzz.hr.bo.impl.ExaminDateUtil;
import com.wyzz.hr.bo.impl.LrDataCheckImpl;
import com.wyzz.hr.pojo.Attendshift;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Leaverequest;
import com.wyzz.hr.pojo.Leavetype;
import com.wyzz.hr.spring.SpringBeanFactory;
import com.wyzz.hr.util.DatabaseSysConfigManager;
import com.wyzz.hr.util.DateUtil;
import com.wyzz.hr.util.StringUtil;
import com.wyzz.hr.util.SystemPropertiesReader;
import com.wyzz.hr.vo.ExaminSearchBean;
import com.wyzz.hr.vo.LeaveFormBean;

public class LrWfApproverAction extends AbstractWfApproverAction {

	public LrWfApproverAction() {
	}

	public void initLRLists() {
		deptList = getDrillDown("Department", new String[] { "1" });
		lrTypeList = getDrillDown("LeaveType", new String[0]);
		statusMap = ComonBeans.getValuesToMap(Leaverequest.PROP_LR_STATUS,
				Status.PROCESS_MAP, new boolean[] { false });
	}

	public String beforeInit(String operate, Object formBean) {
		String msgRejComment = "\u62D2\u7EDD\u7533\u8BF7\u65F6\uFF0C\u5FC5\u987B\u586B\u5199\u5907\u6CE8\uFF01";
		String msgModComment = "\u4FEE\u6539\u540E\u5BA1\u6279\uFF0C\u5FC5\u987B\u586B\u5199\u5907\u6CE8\uFF01";
		String msgCanComment = "\u7533\u8BF7\u4F5C\u5E9F\u65F6\uFF0C\u5FC5\u987B\u586B\u5199\u5907\u6CE8\uFF01";
		String msgSameYear = "\u8BF7\u5047\u5F00\u59CB\u65E5\u671F({0})\u548C\u7ED3\u675F\u65E5\u671F({1})\u5FC5\u987B\u4E3A\u540C\u4E00\u5E74\uFF01";
		String msgBeginTooBig = "\u8BF7\u5047\u5F00\u59CB\u65E5\u671F({0})\u5FC5\u987B\u65E9\u4E8E\u7ED3\u675F\u65E5\u671F({1})\uFF01";
		String msgOwnSubmit = "\u7CFB\u7EDF\u4E0D\u5141\u8BB8\u4ED6\u4EBA\u4EE3\u586B\u8BF7\u5047\u7533\u8BF7\uFF01";
		String msgEarlyDays = "\u5FC5\u987B\u63D0\u524D{0}\u5929\u63D0\u51FA\u8BF7\u5047\u7533\u8BF7\uFF01";
		LeaveFormBean lf_Bean = (LeaveFormBean) formBean;
		if (StringUtils.isEmpty(lf_Bean.getLrAppComment())) {
			if (operate.contains("reject"))
				return msgRejComment;
			if (operate.contains("modify"))
				return msgModComment;
			if (operate.contains("cancel"))
				return msgCanComment;
		}
		if (DateUtil.getYear(lf_Bean.getBeginDate()) != DateUtil
				.getYear(lf_Bean.getBeginDate()))
			return StringUtil.message(msgSameYear, new Object[] {
					lf_Bean.getBeginDate(), lf_Bean.getEndDate() });
		if (lf_Bean.getBeginHour() == null) {
			if (lf_Bean.getBeginApm().intValue() == 0)
				lf_Bean.setBeginDate(DateUtil.parseDateTimeToD(lf_Bean
						.getBeginDate(), 8, 0, 0));
			else
				lf_Bean.setBeginDate(DateUtil.parseDateTimeToD(lf_Bean
						.getBeginDate(), 13, 0, 0));
			if (lf_Bean.getEndApm().intValue() == 1)
				lf_Bean.setEndDate(DateUtil.parseDateTimeToD(lf_Bean
						.getEndDate(), 17, 0, 0));
			else
				lf_Bean.setEndDate(DateUtil.parseDateTimeToD(lf_Bean
						.getEndDate(), 12, 0, 0));
		} else {
			lf_Bean.setBeginDate(DateUtil.parseDateTimeToD(lf_Bean
					.getBeginDate(), lf_Bean.getBeginHour().intValue(), lf_Bean
					.getBeginMinute().intValue(), 0));
			lf_Bean.setEndDate(DateUtil.parseDateTimeToD(lf_Bean.getEndDate(),
					lf_Bean.getEndHour().intValue(), lf_Bean.getEndMinute()
							.intValue(), 0));
		}
		if (lf_Bean.getBeginDate().compareTo(lf_Bean.getEndDate()) >= 0)
			return StringUtil.message(msgBeginTooBig, new Object[] {
					lf_Bean.getBeginDate(), lf_Bean.getEndDate() });
		if (!lf_Bean.getLrEmpNo().equals(getCurrentEmp())) {
			if ((operate.contains("create") || operate.contains("update"))
					&& "0".equals(DatabaseSysConfigManager.getInstance()
							.getProperty("sys.examin.create.level")))
				return msgOwnSubmit;
		} else if (operate.contains("create")) {
			SystemPropertiesReader properties = SystemPropertiesReader
					.getInstance();
			String remind = properties.getValue("LR.Remind.Error");
			Integer days = Integer.valueOf(Integer.parseInt(properties
					.getValue("LR.Remind.Error_own_days")));
			if ("true".equals(remind)) {
				Date allowStartDate = DateUtil.dateAdd(new Date(), days
						.intValue());
				if (DateUtil.compareTwoDay(allowStartDate, lf_Bean
						.getBeginDate()) == -1)
					return StringUtil.message(msgEarlyDays,
							new Object[] { days });
			}
		}
		return "SUCC";
	}

	public Leaverequest objInit(String operate, LeaveFormBean lf_Bean,
			String lrUpdateId) {
		String msgIdError = "\u8F93\u5165\u8BF7\u5047\u5355\u53C2\u6570\u6709\u8BEF\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
		Leaverequest lr = new Leaverequest();
		if (!operate.contains("create")) {
			if (!StringUtils.isEmpty(lrUpdateId)) {
				ILeaverequestBO lr_BO = (ILeaverequestBO) getBean("leaverequestBO");
				lr = lr_BO.loadLeaverequest(lrUpdateId);
			}
			if (lr == null || StringUtils.isEmpty(lr.getLrId())) {
				addErrorInfo(msgIdError);
				return null;
			}
		}
		String fetch[] = { Employee.PROP_EMP_DEPT_NO,
				Employee.PROP_EMP_LOCATION_NO };
		IEmployeeBo empBo = (IEmployeeBo) getBean("empBo");
		Employee emp = empBo.loadEmp(lf_Bean.getLrEmpNo().getId(), fetch);
		lr.setLrEmpNo(emp);
		lr.setApplyLRByDay(lf_Bean.isApplyLRByDay());
		if (lr.isApplyLRByDay()) {
			lr.setLrStartApm(lf_Bean.getBeginApm());
			lr.setLrEndApm(lf_Bean.getEndApm());
		}
		lr.setLrStartDate(lf_Bean.getBeginDate());
		lr.setLrEndDate(lf_Bean.getEndDate());
		if (operate.contains("create") || operate.contains("update")) {
			if (!lf_Bean.getLrLtNo().equals(lr.getLrLtNo())) {
				ILeavetypeBO lt_BO = (ILeavetypeBO) getBean("leavetypeBO");
				Leavetype lrtype = lt_BO.getLeavetype(lf_Bean.getLrLtNo()
						.getLtNo());
				lr.setLrLtNo(lrtype);
			}
			lr.setLrReason(lf_Bean.getLrReason());
		}
		if (!wfInit(operate, lf_Bean.getLrAppComment(), new Object[] { lr }))
			return null;
		else
			return lr;
	}

	public String afterInit(Object obj[]) {
		String msgNoAPM = "\u6309\u5929\u8BF7\u5047\u5FC5\u987B\u586B\u5199\u4E0A\u4E0B\u5348\uFF01";
		String msgNotCreator = "\u60A8\u4E0D\u662F\u7F16\u53F7\u4E3A{0}\u7684\u8BF7\u5047\u5355\u7684\u521B\u5EFA\u8005\uFF01";
		String msgNoReason = "{0}\u5FC5\u987B\u586B\u5199\u8BF7\u5047\u7406\u7531\uFF01";
		String msgCommentDayC = "\u521B\u5EFA\uFF1A{0}\u5929\u7684{1}";
		String msgCommentHourC = "\u521B\u5EFA\uFF1A{0}\u5C0F\u65F6\u7684{1}";
		String msgCommentDayU = "\u6539\u4E3A\uFF1A{0}\u5929\u7684{1}";
		String msgCommentHourU = "\u6539\u4E3A\uFF1A{0}\u5C0F\u65F6\u7684{1}";
		Leaverequest lr = (Leaverequest) obj[0];
		String operate = lr.getWorkflow().getOperate();
		if ((operate.contains("create") || operate.contains("update")
				|| operate.equals("hr-confirm") || operate.contains("modify"))
				&& lr.isApplyLRByDay() && lr.getLrStartApm() == null)
			return msgNoAPM;
		if (operate.contains("update")
				&& !getCurrentEmp().getId().equals(lr.getLrEmpNo().getId())
				&& !getCurrentEmp().getId().equals(lr.getLrCreateBy().getId()))
			return StringUtil.message(msgNotCreator, new Object[] { lr
					.getLrNo() });
		if ((operate.contains("create") || operate.contains("update"))
				&& lr.getLrLtNo().getLtNeedComments().intValue() == 1
				&& (lr.getLrReason() == null || lr.getLrReason().trim().equals(
						"")))
			return StringUtil.message(msgNoReason, new Object[] { lr
					.getLrLtNo().getLtDesc() });
		LrDataCheckImpl lrAddCheckData = (LrDataCheckImpl) getBean("lrDataCheck");
		String info = lrAddCheckData.validateLRDate(lr);
		if (info != "SUCC")
			return info;
		lr.getWorkflow().setAmount(lr.getLrTotalDays());
		info = lrAddCheckData.validateLRConflict(lr);
		if (info != "SUCC")
			return info;
		if (lr.getLrLtNo().getLtSpecialCat().intValue() == 11) {
			info = lrAddCheckData.checkTiaoXiuExp(lr);
			if (info != "SUCC")
				return info;
		}
		if (operate.contains("create")) {
			if (lr.isApplyLRByDay())
				lr.getWorkflow().setComment(
						StringUtil.message(msgCommentDayC,
								new Object[] { lr.getLrTotalDays(),
										lr.getLrLtNo().getLtName() }));
			else
				lr.getWorkflow().setComment(
						StringUtil.message(msgCommentHourC, new Object[] {
								lr.getLrTotalHours(),
								lr.getLrLtNo().getLtName() }));
		} else if (operate.contains("update")) {
			if (lr.isApplyLRByDay())
				lr.getWorkflow().setComment(
						StringUtil.message(msgCommentDayU,
								new Object[] { lr.getLrTotalDays(),
										lr.getLrLtNo().getLtName() }));
			else
				lr.getWorkflow().setComment(
						StringUtil.message(msgCommentHourU, new Object[] {
								lr.getLrTotalHours(),
								lr.getLrLtNo().getLtName() }));
		} else if (operate.contains("reject")) {
			IOvertimetxusedBO overtimetxusedBO = (IOvertimetxusedBO) getBean("overtimetxusedBO");
			overtimetxusedBO.rejectOrCancelLr(new Leaverequest[] { lr });
		}
		return "SUCC";
	}

	public String wfObjOpBatch(String operate, Object formBean,
			String lrUpdateId[]) {
		String msgIEError = "\u6D4F\u89C8\u5668\u53C2\u6570\u5F02\u5E38\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
		String msgNoComment = "\u62D2\u7EDD\u7533\u8BF7\u65F6\uFF0C\u5FC5\u987B\u586B\u5199\u5907\u6CE8\uFF01";
		String msgIdError = "\u8F93\u5165\u8BF7\u5047\u5355\u53C2\u6570\u6709\u8BEF\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
		String msgNoData = "\u672A\u9009\u4E2D\u4EFB\u4F55\u6709\u6548\u8BF7\u5047\u5355\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
		LeaveFormBean lf_Bean = (LeaveFormBean) formBean;
		if (lf_Bean == null) {
			addErrorInfo(msgIEError);
			return "input";
		}
		if (lrUpdateId == null || lrUpdateId.length == 0
				|| StringUtils.isEmpty(lrUpdateId[0])) {
			addErrorInfo(msgIdError);
			return "input";
		}
		if (operate.contains("reject")
				&& StringUtils.isEmpty(lf_Bean.getLrAppComment())) {
			addErrorInfo(msgNoComment);
			return "input";
		}
		String fetch[] = { Leaverequest.PROP_LR_EMP_NO,
				Leaverequest.PROP_LR_EMP_DEPT, Leaverequest.PROP_LR_CREATE_BY,
				Leaverequest.PROP_LR_LT_NO };
		ILeaverequestBO lr_BO = (ILeaverequestBO) getBean("leaverequestBO");
		List lrList = lr_BO.loadLeaveRequests(lrUpdateId, fetch);
		if (lrList == null || lrList.size() == 0) {
			addErrorInfo(msgNoData);
			return "input";
		}
		if (operate.contains("reject")) {
			IOvertimetxusedBO overtimetxusedBO = (IOvertimetxusedBO) getBean("overtimetxusedBO");
			overtimetxusedBO.rejectOrCancelLr((Leaverequest[]) lrList
					.toArray(new Leaverequest[lrList.size()]));
		}
		if (!wfInit(operate, lf_Bean.getLrAppComment(), (Object[]) lrList
				.toArray(new Leaverequest[lrList.size()])))
			return "input";
		else
			return wfObjOperate((Object[]) lrList
					.toArray(new Leaverequest[lrList.size()]));
	}

	public String wfObjOpSingle(String operate, Object formBean,
			String lrUpdateId) {
		String msgIEError = "\u6D4F\u89C8\u5668\u53C2\u6570\u5F02\u5E38\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
		LeaveFormBean lf_Bean = (LeaveFormBean) formBean;
		if (lf_Bean == null) {
			addErrorInfo(msgIEError);
			return "input";
		}
		if (lf_Bean.getLrEmpNo().equals(getCurrentEmp())) {
			if ("hr-create".equals(operate) || "mgr-create".equals(operate))
				operate = "create";
			if ("hr-update".equals(operate) || "mgr-update".equals(operate))
				operate = "update";
		}
		String info = beforeInit(operate, lf_Bean);
		if (!info.equals("SUCC")) {
			addErrorInfo(info);
			return "input";
		}
		Leaverequest lr = objInit(operate, lf_Bean, lrUpdateId);
		if (lr == null)
			return "input";
		info = afterInit(new Object[] { lr });
		if (!info.equals("SUCC")) {
			addErrorInfo(info);
			return "input";
		} else {
			return wfObjOperate(new Object[] { lr });
		}
	}

	public Leaverequest initLfBean(String operate, LeaveFormBean lf_Bean,
			String lrId) {
		Leaverequest lr;
		label0: {
			String msgIdError = "\u8F93\u5165\u8BF7\u5047\u5355\u53C2\u6570\u6709\u8BEF\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5\uFF01";
			lr = new Leaverequest();
			if (!operate.contains("create")) {
				if (lrId != null) {
					ILeaverequestBO lr_BO = (ILeaverequestBO) getBean("leaverequestBO");
					lr = lr_BO.loadOneLeaverequest(lrId, new String[] {
							"lrEmpDept", "lrLtNo", "lrEmpNo" });
				}
				if (lrId == null || lr == null || lr.getLrId() == null) {
					addErrorInfo(msgIdError);
					return null;
				}
			}
			IEmployeeBo empBo = (IEmployeeBo) getBean("empBo");
			if (!operate.contains("create"))
				lf_Bean.setLrEmpNo(lr.getLrEmpNo());
			else if (lf_Bean.getLrEmpNo() != null)
				lf_Bean.setLrEmpNo(empBo.loadEmp(lf_Bean.getLrEmpNo().getId(),
						null));
			else
				lf_Bean.setLrEmpNo(empBo.loadEmp(getCurrentEmpNo(), null));
			ILeavetypeBO lt_BO = (ILeavetypeBO) getBean("leavetypeBO");
			lf_Bean.setAllLtType(lt_BO.FindAllLeaveType());
			Iterator i$;
			Leavetype lt;
			if (lf_Bean.getLrLtNo() == null
					|| lf_Bean.getLrLtNo().getLtNo() == null) {
				if (operate.contains("create"))
					lf_Bean
							.setLrLtNo((Leavetype) lf_Bean.getAllLtType()
									.get(0));
				if (!operate.contains("update") && !operate.contains("modify"))
					break label0;
				i$ = lf_Bean.getAllLtType().iterator();
				do {
					if (!i$.hasNext())
						break label0;
					lt = (Leavetype) i$.next();
				} while (lr.getLrLtNo() == null
						|| !lr.getLrLtNo().getLtNo().equals(lt.getLtNo()));
				lf_Bean.setLrLtNo(lt);
				break label0;
			}
			i$ = lf_Bean.getAllLtType().iterator();
			do {
				if (!i$.hasNext())
					break label0;
				lt = (Leavetype) i$.next();
			} while (!lf_Bean.getLrLtNo().getLtNo().equals(lt.getLtNo()));
			lf_Bean.setLrLtNo(lt);
		}
		if (lf_Bean.getLrReason() == null)
			lf_Bean.setLrReason(lr.getLrReason());
		String leaveType = DatabaseSysConfigManager.getInstance().getProperty(
				"sys.examin.leave.type");
		lf_Bean.setApplyLRByDay(ExaminDateUtil.applyLRByDay(leaveType, lf_Bean
				.getLrLtNo(), lf_Bean.getLrEmpNo().getEmpShiftType()));
		if (lf_Bean.getBeginDate() == null || !lf_Bean.isApplyLRByDay()
				&& DateUtil.getHour(lf_Bean.getEndDate()) == 0
				&& DateUtil.getMinute(lf_Bean.getEndDate()) == 0)
			if (!operate.contains("create")) {
				lf_Bean.setBeginDate(lr.getLrStartDate());
				lf_Bean.setEndDate(lr.getLrEndDate());
			} else {
				IAttendshiftBO attendBo = (IAttendshiftBO) getBean("attendshiftBO");
				Attendshift defaultAs = attendBo.getDefaultAttendshiftByEmp(lr
						.getLrEmpNo());
				if (lf_Bean.getBeginDate() == null) {
					Date dates[] = ExaminDateUtil.getShiftArr(new Date(),
							defaultAs.getAttsSession());
					System.out.println(dates[0]+"kkkkk"+dates[1]);
					lf_Bean.setBeginDate(dates[0]);
					lf_Bean.setEndDate(dates[1]);
				} else {
					Date dates[] = ExaminDateUtil.getShiftArr(lf_Bean
							.getBeginDate(), defaultAs.getAttsSession());
					lf_Bean.setBeginDate(dates[0]);
					if (DateUtil.dateDiff(lf_Bean.getBeginDate(), lf_Bean
							.getEndDate(), 5) != 0)
						dates = ExaminDateUtil.getShiftArr(
								lf_Bean.getEndDate(), defaultAs
										.getAttsSession());
					lf_Bean.setEndDate(dates[1]);
				}
			}
		if (lf_Bean.isApplyLRByDay()) {
			if (lf_Bean.getBeginApm() == null) {
				lf_Bean.setBeginApm(Integer
						.valueOf(lr.getLrStartApm() != null ? lr
								.getLrStartApm().intValue() : 0));
				lf_Bean.setEndApm(Integer.valueOf(lr.getLrEndApm() != null ? lr
						.getLrEndApm().intValue() : 1));
			}
			if (lr.getLrTotalDays() != null)
				lf_Bean.setTotalTime((new StringBuilder()).append(
						StringUtil.formatBDToS(lr.getLrTotalDays(),
								new String[0])).append("\u5929").toString());
		} else {
			if (lf_Bean.getBeginHour() == null) {
				lf_Bean.setBeginHour(Integer.valueOf(DateUtil.getHour(lf_Bean
						.getBeginDate())));
				lf_Bean.setBeginMinute(Integer.valueOf(DateUtil
						.getMinute(lf_Bean.getBeginDate())));
				lf_Bean.setEndHour(Integer.valueOf(DateUtil.getHour(lf_Bean
						.getEndDate())));
				lf_Bean.setEndMinute(Integer.valueOf(DateUtil.getMinute(lf_Bean
						.getEndDate())));
			}
			if (lr.getLrTotalHours() != null)
				lf_Bean.setTotalTime((new StringBuilder()).append(
						lr.getLrTotalHours().toString()).append("\u5C0F\u65F6")
						.toString());
			if (lf_Bean.getBeginHour().intValue() == 24)
				lf_Bean.setBeginDate(DateUtil.dateAdd(lf_Bean.getBeginDate(),
						-1));
			if (lf_Bean.getEndHour().intValue() == 24)
				lf_Bean.setEndDate(DateUtil.dateAdd(lf_Bean.getEndDate(), -1));
		}
		if (operate.contains("modify")) {
			LrDataCheckImpl lrAddCheckData = (LrDataCheckImpl) getBean("lrDataCheck");
			String info = lrAddCheckData.validateLRDate(lr);
			String info2 = lrAddCheckData.validateLRConflict(lr);
			if (!info.equals("SUCC") || !info2.equals("SUCC"))
				addSuccessInfo((new StringBuilder()).append(info).append(" ")
						.append(info2).toString());
			if (lr.getLrLtNo().getLtSpecialCat().intValue() == 11) {
				IOvertimerequestBo overtimerequestBO = (IOvertimerequestBo) getBean("overtimerequestBO");
				double leaveDate[] = overtimerequestBO
						.countHoursAndRemainHours(lf_Bean.getLrEmpNo().getId(),
								lr.getLrStartDate());
				lr.setUseableHours(new BigDecimal(leaveDate[0]));
				lr.setUseableDays(new BigDecimal(leaveDate[0]
						/ lr.getHoursPerDay()));
				lr.setUsedHours(new BigDecimal(leaveDate[0] - leaveDate[1]));
				lr.setUsedDays(new BigDecimal((leaveDate[0] - leaveDate[1])
						/ lr.getHoursPerDay()));
				lr.setRemainHours(new BigDecimal(leaveDate[1]));
				lr.setRemainDays(new BigDecimal(leaveDate[1]
						/ lr.getHoursPerDay()));
			}
			if (lf_Bean.isApplyLRByDay()) {
				lf_Bean.setStartTime(DateUtil
						.formatDateByApm(lr.getLrStartDate(),
								new Integer[] { lr.getLrStartApm() }));
				lf_Bean.setEndTime(DateUtil.formatDateByApm(lr.getLrEndDate(),
						new Integer[] { lr.getLrEndApm() }));
				if (lr.getUseableDays() != null)
					lf_Bean
							.setUseableTime((new StringBuilder()).append(
									StringUtil.formatBDToS(lr.getUseableDays(),
											new String[0])).append("\u5929")
									.toString());
				if (lr.getUsedDays() != null)
					lf_Bean
							.setUsedTime((new StringBuilder()).append(
									StringUtil.formatBDToS(lr.getUsedDays(),
											new String[0])).append("\u5929")
									.toString());
				if (lr.getRemainDays() != null)
					lf_Bean
							.setRemainTime((new StringBuilder()).append(
									StringUtil.formatBDToS(lr.getRemainDays(),
											new String[0])).append("\u5929")
									.toString());
			} else {
				lf_Bean.setStartTime(DateUtil.formatDateByApm(lr
						.getLrStartDate(), new Integer[0]));
				lf_Bean.setEndTime(DateUtil.formatDateByApm(lr.getLrEndDate(),
						new Integer[0]));
				if (lr.getUseableHours() != null)
					lf_Bean.setUseableTime((new StringBuilder()).append(
							lr.getUseableHours().toString()).append(
							"\u5C0F\u65F6").toString());
				if (lr.getUsedHours() != null)
					lf_Bean.setUsedTime((new StringBuilder()).append(
							lr.getUsedHours().toString())
							.append("\u5C0F\u65F6").toString());
				if (lr.getRemainHours() != null)
					lf_Bean.setRemainTime((new StringBuilder()).append(
							lr.getRemainHours().toString()).append(
							"\u5C0F\u65F6").toString());
			}
			String statusDesc = ComonBeans.getParameterValue("lrStatus",
					new String[] { lr.getLrStatus().toString() });
			lf_Bean.setLrStatus(statusDesc);
			ISysLogBO logBO = (ISysLogBO) SpringBeanFactory.getBean("logBO");
			lf_Bean.setLogList(logBO.getLogs("leaverequest", lr.getLrId()));
		}
		return lr;
	}

	public void validateDate(ExaminSearchBean es_Bean) {
		if (es_Bean != null) {
			if (es_Bean.getEndDate() != null
					&& es_Bean.getStartDate() != null
					&& es_Bean.getStartDate().getTime() > es_Bean.getEndDate()
							.getTime())
				addErrorInfo("\u5F00\u59CB\u65F6\u95F4\u5E94\u5C0F\u4E8E\u7ED3\u675F\u65F6\u95F4\uFF01");
			if (es_Bean.getEndDate() == null && es_Bean.getStartDate() != null
					|| es_Bean.getEndDate() != null
					&& es_Bean.getStartDate() == null)
				addErrorInfo("\u5FC5\u987B\u540C\u65F6\u586B\u5199\u5F00\u59CB\u548C\u7ED3\u675F\u65E5\u671F\uFF01");
		}
	}

	public void validateLRStatus(ExaminSearchBean es_Bean) {
		if (es_Bean != null && es_Bean.getStatu() != null
				&& es_Bean.getStatu().intValue() != 0
				&& es_Bean.getStatu().intValue() != 22
				&& es_Bean.getStatu().intValue() != 14
				&& es_Bean.getStatu().intValue() != 15
				&& es_Bean.getStatu().intValue() != 21
				&& es_Bean.getStatu().intValue() != 2
				&& es_Bean.getStatu().intValue() != 16
				&& es_Bean.getStatu().intValue() != 5)
			addErrorInfo("Invalidate Status");
	}
}
